#ifndef TIMER_TASK_H_
#define TIMER_TASK_H_

#include "timer_channel.h"

#include <cstdint>
#include <functional>
#include <memory>

class Loop;
class TimerTask
{
public:
    using TimerFunc = std::function<void()>;
public:
    explicit TimerTask(Loop * loop);
    ~TimerTask();
    int  ExpireFromNow(int ms, TimerFunc && callback);
    int  ExpireAt(int64_t timestamp_ms, TimerFunc && callback);
    void Cancel();
private:
    Loop * m_loop;
    std::shared_ptr<TimerChannel> m_timer_channel;
    std::shared_ptr<Description>  m_description;
    int                           m_event_type;
};

typedef TimerTask ScheduleEvent;

#endif
